snapshot: Don't flip textures
authorBenjamin Otte <otte@redhat.com>
Mon, 28 Sep 2020 14:09:06 +0000 (16:09 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 28 Sep 2020 14:14:28 +0000 (16:14 +0200)
... or gradients or borders or shadows. Instead, ensure that affines
have non-negative scale factors. Otherwise add a transform node.

The only place where this check is not necessary is color nodes, but
special casing them seems not worth it.

gtk/gtksnapshot.c

index 7de659416785388c5f169aec21daed941c4840d3..a1d7c9340c7838bdebfa7e8d21a6388d9d1f1262 100644 (file)
@@ -697,9 +697,22 @@ gtk_snapshot_ensure_affine (GtkSnapshot *snapshot,
     {
       gtk_snapshot_autopush_transform (snapshot);
       state = gtk_snapshot_get_current_state (snapshot);
+      gsk_transform_to_affine (state->transform, scale_x, scale_y, dx, dy);
+    }
+  else if (gsk_transform_get_category (state->transform) == GSK_TRANSFORM_CATEGORY_2D_AFFINE)
+    {
+      gsk_transform_to_affine (state->transform, scale_x, scale_y, dx, dy);
+      if (*scale_x < 0.0 || *scale_y < 0.0)
+        {
+          gtk_snapshot_autopush_transform (snapshot);
+          state = gtk_snapshot_get_current_state (snapshot);
+          gsk_transform_to_affine (state->transform, scale_x, scale_y, dx, dy);
+        }
+    }
+  else
+    {
+      gsk_transform_to_affine (state->transform, scale_x, scale_y, dx, dy);
     }
-  
-  gsk_transform_to_affine (state->transform, scale_x, scale_y, dx, dy);
 }
 
 static void